package com.example.demo.controller;

import lombok.Data;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController("get")
public class GetController {

    @RequestMapping(path = "g", method = RequestMethod.GET)
    public String g(Model model) {
        System.out.println(model.getId());
        System.out.println(model.getName());
        return model.toString();
    }

    @RequestMapping(path = "g2", method = RequestMethod.POST)
    public String g2() {
        boolean flag = true;
        if (flag) {
            throw new RuntimeException("我是一个异常");
        }
        return "222";
    }

    @Data
    public static class Model {
        private Integer id;
        private String name;
    }
}
